home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / outwin.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  4KB  |  115 lines

  1. /*  OUTWIN.H    Window for output of the hypertext. Use different fonts,
  2.         colors, icons. Context jmps and jmps back.
  3. */
  4.  
  5. #ifndef __OUTPIUT_WINDOW_H_
  6. #define __OUTPIUT_WINDOW_H_
  7.  
  8. #include "window.h"
  9. #include "cursor.h"
  10. #include "icon.h"
  11.  
  12. enum { REFLECT, VIEW };
  13.  
  14.                    // Maximum number of contexts on one page
  15. #define MAXKEYS 100
  16.  
  17. #define st_page_height 60
  18. #define max_string_len 100
  19. #define num_pages 200
  20. #define previous_num 50
  21.  
  22. struct context
  23.     {                      // We use 8-char identifier for marking of the
  24.     char cont_name[10];    // context.
  25.     int page;              // Page to which we must jump
  26.     int line;              // line at this page
  27.  
  28. /*
  29. Unremark for BC++ 2.0
  30.  
  31.    context()
  32.     { cont_name[0] = page = line = 0; }
  33. */
  34.     context(char* c_n = 0, int p = 0, int l = 0)
  35.     {
  36.     if(c_n)
  37.         strcpy(cont_name, c_n);
  38.     else                             // c_n == 0
  39.         cont_name[0] = 0;
  40.     page = p;
  41.     line = l;
  42.     }
  43.     };
  44. /////////////////////
  45. struct special              // ltrb is the rectangle - if mouse or OK - like
  46.     {                       // key is pressed at this area we jumps to the
  47.     rect ltrb;              // corresponding context
  48.     char cont_name[10];
  49.     };
  50. //////////////////////
  51. struct prev_stek                    // This stek contains pages and lines
  52.     {                               // of previous contexts. It is used
  53.     loc previous[previous_num];     // in the same maner as in BC++ help
  54.     int used;                       // system, when ALT-F1 pressed.
  55.     prev_stek() { used = 0; }
  56.     void add(loc to_add);
  57.     loc remove()
  58.     {
  59.     if(used)
  60.         {
  61.         used--;
  62.         return previous[used + 1];
  63.         }
  64.     else return loc(0, 0);
  65.     }
  66.     };
  67. //////////////////////
  68. class OutputWindow : public Window
  69.     {
  70.     protected:
  71.         special* key_rects;  // around "special" places at the page
  72.         context* contexts;   // list of contexts and its coordinates in file
  73.         int number;          // number of special rectangles
  74.  
  75.         loc curs;            // curs (0, 0) is in left-top screen corner
  76.         loc start;           // text coordinates
  77.         char* page;          // 1/2 page (1/2 of page is the loaded unit)
  78.         char* viewName;      // hypertext file name
  79.         int bak_color;
  80.         int attr_color;
  81.         int interval;        // text output interval
  82.         int end;             // flag end shows, is this page last in file
  83.         Cursor cursor;       // in screen coords
  84.         int page_height;
  85.         long file_position;
  86.         long* pages;         // page file positions list
  87.  
  88.         prev_stek listed;    // stek of previously visited contexts
  89.     public:
  90.     OutputWindow(rect coordinates, char* vName,
  91.            int b_type = 1, int s = 3, int bak = pColorSet->colors.BAK_COLOR,
  92.            int attr = pColorSet->colors.ATTR_COLOR,
  93.            int interv = pScreenSet->sub_interval,
  94.            int p_height = st_page_height);
  95.  
  96.     virtual ~OutputWindow();
  97.  
  98.     void init_pages(); //pages[0] keeps current page number
  99.  
  100.     loc process(char*, char*, int flag,           // commands processing,
  101.             int count_ret, int is_first = 0); // f.e. change color
  102.     void view();                                  // output
  103.     void box_move(int dir);                       // navigation
  104.     virtual void show();
  105.     virtual void exe(int act = 0);
  106.     void mouse_curs(loc ms_pos);                  // move cursor to ms position
  107.     int load();                                   // create index table
  108.     void load_file();                             // load part of file
  109.     void key_add(loc wh, char* name);             // to context list
  110.     int on_special();                             // is it special place?
  111.     void jmp_to(char* context);
  112.     };
  113.  
  114.  
  115. #endif __OUTPIUT_WINDOW_H_